//二维转一维，多维转一维
let arr=[2,4,[6,7]];
function flatten(arr){
    return arr.reduce(function(prev,cur){
        return prev.concat(Array.isArray(cur)?flatten(cur):cur)
    },[])
}
console.log(flatten(arr))
//[2,4,6,7]
//多维转一维
let arr1=[1,2,3,[4,5],6];
let arr2=arr1.flat();
console.log(arr2)
//[1,2,3,4,5,6]